package com.enation.app.javashop.core.client.fallback.payment;

import com.enation.app.javashop.core.client.feignimpl.payment.PaymentClientFeignImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.enation.app.javashop.model.payment.dos.PaymentMethodDO;
import com.enation.app.javashop.model.payment.dto.PayParam;
import org.springframework.stereotype.Component;

import java.util.Map;

/**
 * 支付中心client熔断 factory
 * @author kingapex
 * @version 1.0
 * @data 2022/5/28 14:59
 **/
@Component
public class PaymentClientFallbackFactory extends BaseFallbackFactory<PaymentClientFeignImpl> {
    @Override
    protected PaymentClientFeignImpl fallback() {
        return new PaymentClientFallback();
    }

    /**
     * 支付中心client熔断
     *
     * @author fk
     * @version v7.0
     * @date 20/3/11 下午3:27
     * @since v7.2.1
     */
    @Component
    public static class PaymentClientFallback implements PaymentClientFeignImpl {

        private final Logger logger = LoggerFactory.getLogger(getClass());

        @Override
        public Map pay(PayParam param) {
            logger.error("支付失败，支付信息："+param);
            return null;
        }

        @Override
        public String queryBill(String subSn, String serviceType) {

            logger.error("查询账单失败subSn："+subSn+"，serviceType："+serviceType);
            return null;
        }

        @Override
        public PaymentMethodDO getByPluginId(String pluginId) {

            logger.error("查询支付方式出错："+pluginId);
            return null;
        }
    }
}
